﻿#ifndef __CXMLFactoryEnvironment_H__
#define __CXMLFactoryEnvironment_H__
#include <lampe/types.h>
#include <lampe/IReferenceCounted.h>
#include <lampe/xml/IFactoryRecord.h>
#include <lampe/xml/IXmlNode.h>
#include <lampe/stream/IReader.h>
#include <lampe/xml/IXMLFactoryEnvironment.h>

namespace lampe{
namespace xml{

class CXMLFactoryEnvironment:public IXMLFactoryEnvironment{
private:
	LAMPE_MAP_VENDOR<String,IFactoryRecord*> tags;
	LAMPE_MAP_VENDOR<String,IFactoryRecord*> attributes;
	//LAMPE_MAP_VENDOR<String name,IFactoryRecord*> tags;
	//LAMPE_MAP_VENDOR<String name,IFactoryRecord*> attributes;
	void addTagHandler(String name,IFactoryRecord*handler);
	void addAttributeHandler(String name,IFactoryRecord*handler);
	io::IFileSystem*fileSystem;
	//irr::IrrlichtDevice*device;
	//irr::io::IFileSystem*fileSystem;
public:
	virtual void registerHandler(IFactoryRecord*record);
	//virtual IrrlichtDevice*getDevice();
	virtual IFactoryRecord*getFactoryByTagName(String);
	virtual IFactoryRecord*getFactoryByAttributeName(String);
	
	virtual void removeHandlerFromTag(String name);
	virtual void removeHandlerFromAttribute(String name);
	virtual lampe::xml::TagResult runNode(IXmlNode*node);
	//virtual IXmlNode*getXmlTree(String fileName);
	//virtual IXmlNode*getXmlTree(irr::io::IReadFile*stream,String fileName);
	
	virtual IXmlNode*createXmlTree(boost::filesystem::path fileName);
	virtual IXmlNode*createXmlTree(stream::IReader*fileStream);
	virtual void regSimpeTag(lampe::String element,XMLTagFactoryFunction function);
	virtual void regSimpeAttribute(lampe::String element,XMLAttribyteFactoryFunction function);
	virtual lampe::io::IFileSystem*getFileSystem();

	CXMLFactoryEnvironment(io::IFileSystem*fileSystem);
	virtual ~CXMLFactoryEnvironment();
};

}//namespace xml
}//namespace lampe
#endif
